﻿Public Class IngresoDato
    Dim Type As String
    Private Sub IngresoDato_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        xDato.Focus()
    End Sub
    Public Sub New(ByVal xTitulo As String, ByVal xMensaje As String, Optional ByVal xSufijo As String = "")

        ' Llamada necesaria para el diseñador.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        Me.Text = xTitulo
        Me.lbMensaje.Text = xMensaje

        Me.lbSufijo.Text = xSufijo
        Me.xDato.Focus()
    End Sub

    Private Sub xDato_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xDato.KeyPress
        If e.KeyChar = vbCr Then
            Aceptar()
        End If
        If e.KeyChar = ChrW(Keys.Escape) Then
            Me.Dispose()
        End If
        If Char.IsDigit(e.KeyChar) Then
            e.Handled = False
        ElseIf Char.IsControl(e.KeyChar) Then
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub xDato_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles xDato.TextChanged

        Try
            Dim mt As Double = xDato.Text
            xDato.Text = mt.ToString("##,##")
            xDato.Select(xDato.ToString.Length, xDato.ToString.Length)
        Catch ex As Exception
        End Try
        xDato.Focus()
    End Sub
    Public Function GetValue() As Integer
        If xDato.TextLength > 0 Then
            Return CDbl(xDato.Text)
        Else
            Return 0
        End If

        Me.Dispose()
    End Function

    Private Sub bAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bAceptar.Click
        Aceptar()
    End Sub

    Private Sub Aceptar()
        If xDato.Text = "" Then
            ' Util.Mensaje("Debe Ingresar el Valor")
            ' xDato.Focus()
            'Else

        End If
        Me.DialogResult = DialogResult.OK
    End Sub

    Private Sub bCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bCancelar.Click
        Dispose()
    End Sub
End Class